package com.example.a79273.shandianban.model;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 79273 on 2016/8/31.
 */
public class YouLiaoContent {

    /**
     * error_code : 0
     * error_msg : 获取数据成功
     * total : 2
     * data : {"list":[{"fid":"234001674729","fname":"人物","id":"234001674729","title":"【设计师专访】刘洋：我是一名职业服装设计师","href":"api/Resource/GetDetail/234001674729","scr":"/Upload/Document/234001674729/367bc3f901.jpg"},{"fid":"234001674942","fname":"人物","id":"234001674942","title":"【设计师专访】对话「衫点扮」创始人Andy","href":"api/Resource/GetDetail/234001674942","scr":"/Upload/Document/234001674942/367be27ce0.jpg"}],"page_info":{"page_count":2,"page":1,"page_size":10}}
     */

    private int error_code;
    private String error_msg;
    private int total;
    /**
     * list : [{"fid":"234001674729","fname":"人物","id":"234001674729","title":"【设计师专访】刘洋：我是一名职业服装设计师","href":"api/Resource/GetDetail/234001674729","scr":"/Upload/Document/234001674729/367bc3f901.jpg"},{"fid":"234001674942","fname":"人物","id":"234001674942","title":"【设计师专访】对话「衫点扮」创始人Andy","href":"api/Resource/GetDetail/234001674942","scr":"/Upload/Document/234001674942/367be27ce0.jpg"}]
     * page_info : {"page_count":2,"page":1,"page_size":10}
     */

    private DataBean data;

    public static YouLiaoContent objectFromData(String str) {

        return new Gson().fromJson(str, YouLiaoContent.class);
    }

    public static YouLiaoContent objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), YouLiaoContent.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<YouLiaoContent> arrayYouLiaoContentFromData(String str) {

        Type listType = new TypeToken<ArrayList<YouLiaoContent>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<YouLiaoContent> arrayYouLiaoContentFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<YouLiaoContent>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public int getError_code() {
        return error_code;
    }

    public void setError_code(int error_code) {
        this.error_code = error_code;
    }

    public String getError_msg() {
        return error_msg;
    }

    public void setError_msg(String error_msg) {
        this.error_msg = error_msg;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * page_count : 2
         * page : 1
         * page_size : 10
         */

        private PageInfoBean page_info;
        /**
         * fid : 234001674729
         * fname : 人物
         * id : 234001674729
         * title : 【设计师专访】刘洋：我是一名职业服装设计师
         * href : api/Resource/GetDetail/234001674729
         * scr : /Upload/Document/234001674729/367bc3f901.jpg
         */

        private List<ListBean> list;

        public static DataBean objectFromData(String str) {

            return new Gson().fromJson(str, DataBean.class);
        }

        public static DataBean objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataBean.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataBean> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataBean> arrayDataBeanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataBean>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public PageInfoBean getPage_info() {
            return page_info;
        }

        public void setPage_info(PageInfoBean page_info) {
            this.page_info = page_info;
        }

        public List<ListBean> getList() {
            return list;
        }

        public void setList(List<ListBean> list) {
            this.list = list;
        }

        public static class PageInfoBean {
            private int page_count;
            private int page;
            private int page_size;

            public static PageInfoBean objectFromData(String str) {

                return new Gson().fromJson(str, PageInfoBean.class);
            }

            public static PageInfoBean objectFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);

                    return new Gson().fromJson(jsonObject.getString(str), PageInfoBean.class);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return null;
            }

            public static List<PageInfoBean> arrayPageInfoBeanFromData(String str) {

                Type listType = new TypeToken<ArrayList<PageInfoBean>>() {
                }.getType();

                return new Gson().fromJson(str, listType);
            }

            public static List<PageInfoBean> arrayPageInfoBeanFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);
                    Type listType = new TypeToken<ArrayList<PageInfoBean>>() {
                    }.getType();

                    return new Gson().fromJson(jsonObject.getString(str), listType);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return new ArrayList();


            }

            public int getPage_count() {
                return page_count;
            }

            public void setPage_count(int page_count) {
                this.page_count = page_count;
            }

            public int getPage() {
                return page;
            }

            public void setPage(int page) {
                this.page = page;
            }

            public int getPage_size() {
                return page_size;
            }

            public void setPage_size(int page_size) {
                this.page_size = page_size;
            }
        }

        public static class ListBean {
            private String fid;
            private String fname;
            private String id;
            private String title;
            private String href;
            private String scr;

            public static ListBean objectFromData(String str) {

                return new Gson().fromJson(str, ListBean.class);
            }

            public static ListBean objectFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);

                    return new Gson().fromJson(jsonObject.getString(str), ListBean.class);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return null;
            }

            public static List<ListBean> arrayListBeanFromData(String str) {

                Type listType = new TypeToken<ArrayList<ListBean>>() {
                }.getType();

                return new Gson().fromJson(str, listType);
            }

            public static List<ListBean> arrayListBeanFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);
                    Type listType = new TypeToken<ArrayList<ListBean>>() {
                    }.getType();

                    return new Gson().fromJson(jsonObject.getString(str), listType);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return new ArrayList();


            }

            public String getFid() {
                return fid;
            }

            public void setFid(String fid) {
                this.fid = fid;
            }

            public String getFname() {
                return fname;
            }

            public void setFname(String fname) {
                this.fname = fname;
            }

            public String getId() {
                return id;
            }

            public void setId(String id) {
                this.id = id;
            }

            public String getTitle() {
                return title;
            }

            public void setTitle(String title) {
                this.title = title;
            }

            public String getHref() {
                return href;
            }

            public void setHref(String href) {
                this.href = href;
            }

            public String getScr() {
                return scr;
            }

            public void setScr(String scr) {
                this.scr = scr;
            }
        }
    }
}
